﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NETMovie.UI.WebMVC.Models;
using NETMovie.Entities;

namespace NETMovie.UI.WebMVC.Mappers
{
    public class RentalMapper
    {
        public ViewRentalRecordModel ReMap(MovieRental rental)
        {
            ViewRentalRecordModel model = new ViewRentalRecordModel();
            model.MovieRentalID = rental.MovieRentalId;
            model.MovieName = rental.Movie.Title;
            model.IsPremium = rental.Movie.IsPremium;
            model.Price = rental.Amount;
            model.DueDate = rental.EndDate;

            return model;
        }

        public ViewRentalsModel ReMap(MovieRental[] rentals)
        {
            ViewRentalsModel model = new ViewRentalsModel();
            model.RentalRecords = new List<ViewRentalRecordModel>();
            if (rentals == null)
                return model;

            for (int i = 0; i < rentals.Length; i++)
            {
                model.RentalRecords.Add(ReMap(rentals[i]));
            }

            return model;
        }
    }
}